<?php
namespace Home\Controller;

use Think\Controller;

class CompanylistController extends Controller {
	 // 公司列表页
	public function index(){
        
        $jobObj = D('Job');
        $tagModel = D('Tag');
        $comObj = D('Company');
        $total = $comObj->count();
        $page = new \Think\Page($total, 15);
        $page->setConfig('first', '首页');
        $page->setConfig('prev', '上一页');
        $page->setConfig('next', '下一页');
        $page->setConfig('last', '尾页');
        $res = $comObj->limit($page->firstRow, $page->listRows)->select();
        foreach ($res as &$val) {
            $res2 = $tagModel->getList($val['id']);
            $res3 = $jobObj->where(array('company_id'=>$val['id']))->limit(4)->select();
            $val['tag'] = $res2;
            $val['job'] = $res3;
        }

        $tradeObj = D('Trade');
        $trade = $tradeObj->select();

        $this->assign('page', $page->show());
        $this->assign('trade', $trade);
        $this->assign('company', $res);

         $cate=D('cate');
        $ca=$cate->select();
        //var_dump($cates);exit;
        $this->assign('ca',$ca);

	

      $this->display();
    }

}